﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using LispInterpretor;
using LispInterpretor.DataTypes;

namespace UnitTests
{
    [TestClass]
    public class TestLists
    {
        private Number one = new Number(1, 1);
        private Number two = new Number(2, 1);
        private Number three = new Number(3, 1);
        private Number four = new Number(4, 1);

        [TestMethod]
        public void TestBasicList()
        {
            object result = Evaluator.Eval("(1 2 3 4)");

            Assert.IsTrue(result is IList<object>);

            IList<object> list = (IList<object>) result;

            Assert.AreEqual(4, list.Count);

            Assert.AreEqual(one, list[0]);
            Assert.AreEqual(two, list[1]);
            Assert.AreEqual(three, list[2]);
            Assert.AreEqual(four, list[3]);

        }

        [TestMethod]
        public void TestListWithInbeddedFunctions()
        {
            object result = Evaluator.Eval("(1 2 (+ 3 5) 4)");

            Assert.IsTrue(result is IList<object>);

            IList<object> list = (IList<object>)result;

            Assert.AreEqual(4, list.Count);

            Assert.AreEqual(one, list[0]);
            Assert.AreEqual(two, list[1]);
            Assert.AreEqual(new Number(8,1), list[2]);
            Assert.AreEqual(four, list[3]);
        }
    }
}
